package com.starblink.library.widget.product

import android.util.Log
import android.view.ViewGroup
import androidx.recyclerview.widget.RecyclerView
import com.scwang.smart.refresh.layout.SmartRefreshLayout
import com.starblink.android.basic.adapter.BaseVH
import com.starblink.android.basic.data.model.product.RecommendProductF
import com.starblink.library.widget.product.util.TrackUtil

class RecommendProductCardCell(
    private val refreshLayout: SmartRefreshLayout,
    private val recyclerView: RecyclerView,
    parent: ViewGroup,
    private val feedsScene: ProductCardScene? = null,
    var pageTrackTag: String? = null,
) :
    BaseVH<RecommendProductF>(ProductCardView(parent.context)) {

    private companion object {
        const val TAG = "RecommendProductCardCell"
    }

    private val cardView = itemView as ProductCardView

    override fun onBind(model: RecommendProductF, position: Int) {
        //Log.d(TAG, "onBind: position: ${position}, name: ${model.title}")
        cardView.scene = feedsScene
        cardView.bindProduct(
            model,
            spmPageValue = TrackUtil.transformPageValue(feedsScene),
            position = position,
            guideType = TAG,
            refreshLayout = refreshLayout,
            recyclerView = recyclerView
        )
    }
}